Skip to content

Expanded Product struct nutrients#10

Merged
LightJack05 merged 1 commit intomainfrom
product-struct
Jan 16, 2026
Merged

Expanded Product struct nutrients#10
LightJack05 merged 1 commit intomainfrom
product-struct

Conversation

@LightJack05
Copy link
Contributor

No description provided.

@LightJack05 LightJack05 self-assigned this Jan 16, 2026
Copilot AI review requested due to automatic review settings January 16, 2026 16:42
@LightJack05 LightJack05 merged commit aa18f8b into main Jan 16, 2026
12 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request expands the Nutriments struct within the Product type to include a more comprehensive set of nutritional fields. The changes replace a minimal set of 33 nutrient fields with an expanded set of 65 fields, adding support for various fat types (saturated, monounsaturated, polyunsaturated, trans), sodium/salt measurements, nova groups, nutrition scores, and fruit/vegetable estimates.

Changes:

  • Replaced all fields in the Nutriments struct with an expanded and reorganized set of nutritional data fields
  • Changed several field types from int to float64 for better precision in nutritional data
  • Removed sugar-specific fields (Sugars, SugarsValue, SugarsUnit, Sugars100G, SugarsServing) which may be a breaking change
  • Added new fields for trans fats, polyunsaturated fats, monounsaturated fats, saturated fats, salt, sodium, nova groups, and nutrition scores

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -296,37 +296,71 @@ type Product struct {
TracesTags []interface{} `json:"traces_tags" bson:"traces_tags,truncate"`
Rev int `json:"rev" bson:"rev,truncate"`
Nutriments struct {
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of sugar-related fields (Sugars, SugarsValue, SugarsUnit, Sugars100G, SugarsServing) from the Nutriments struct represents a breaking API change. If these fields are used by API consumers or exist in the database, their removal could cause data loss or runtime errors during JSON/BSON deserialization. Consider either retaining these fields alongside the new ones, or verify that these fields are not present in the actual data source and are not consumed by any clients.

Copilot uses AI. Check for mistakes.
Comment on lines +304 to +316
EnergyKcalValue float64 `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"`
MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"`
FatValue float64 `json:"fat_value" bson:"fat_value,truncate"`
FruitsVegetablesLegumesEstimateFromIngredientsServing float64 `json:"fruits-vegetables-legumes-estimate-from-ingredients_serving" bson:"fruits-vegetables-legumes-estimate-from-ingredients_serving,truncate"`
ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"`
TransFatValue float64 `json:"trans-fat_value" bson:"trans-fat_value,truncate"`
FruitsVegetablesNutsEstimateFromIngredientsServing float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_serving" bson:"fruits-vegetables-nuts-estimate-from-ingredients_serving,truncate"`
EnergyServing float64 `json:"energy_serving" bson:"energy_serving,truncate"`
SaturatedFatValue float64 `json:"saturated-fat_value" bson:"saturated-fat_value,truncate"`
ProteinsUnit string `json:"proteins_unit" bson:"proteins_unit"`
Salt float64 `json:"salt" bson:"salt,truncate"`
Carbohydrates float64 `json:"carbohydrates" bson:"carbohydrates,truncate"`
Salt100g float64 `json:"salt_100g" bson:"salt_100g,truncate"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field type changed from int to float64 for energy-related fields. While this provides better precision, it's a breaking change if clients are expecting integer values in JSON responses. Verify that downstream consumers can handle decimal values for these fields.

Suggested change
EnergyKcalValue float64 `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"`
MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"`
FatValue float64 `json:"fat_value" bson:"fat_value,truncate"`
FruitsVegetablesLegumesEstimateFromIngredientsServing float64 `json:"fruits-vegetables-legumes-estimate-from-ingredients_serving" bson:"fruits-vegetables-legumes-estimate-from-ingredients_serving,truncate"`
ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"`
TransFatValue float64 `json:"trans-fat_value" bson:"trans-fat_value,truncate"`
FruitsVegetablesNutsEstimateFromIngredientsServing float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_serving" bson:"fruits-vegetables-nuts-estimate-from-ingredients_serving,truncate"`
EnergyServing float64 `json:"energy_serving" bson:"energy_serving,truncate"`
SaturatedFatValue float64 `json:"saturated-fat_value" bson:"saturated-fat_value,truncate"`
ProteinsUnit string `json:"proteins_unit" bson:"proteins_unit"`
Salt float64 `json:"salt" bson:"salt,truncate"`
Carbohydrates float64 `json:"carbohydrates" bson:"carbohydrates,truncate"`
Salt100g float64 `json:"salt_100g" bson:"salt_100g,truncate"`
EnergyKcalValue int `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"`
MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"`
FatValue float64 `json:"fat_value" bson:"fat_value,truncate"`
FruitsVegetablesLegumesEstimateFromIngredientsServing float64 `json:"fruits-vegetables-legumes-estimate-from-ingredients_serving" bson:"fruits-vegetables-legumes-estimate-from-ingredients_serving,truncate"`
ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"`
TransFatValue float64 `json:"trans-fat_value" bson:"trans-fat_value,truncate"`
FruitsVegetablesNutsEstimateFromIngredientsServing float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_serving" bson:"fruits-vegetables-nuts-estimate-from-ingredients-servin

Copilot uses AI. Check for mistakes.
EnergyKcal100g float64 `json:"energy-kcal_100g" bson:"energy-kcal_100g,truncate"`
EnergyKcalValue float64 `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"`
MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"`
FatValue float64 `json:"fat_value" bson:"fat_value,truncate"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fat-related fields changed from int to float64. This is a type-breaking change that could affect API consumers expecting integer values. Ensure all clients can handle floating-point values for fat measurements.

Suggested change
FatValue float64 `json:"fat_value" bson:"fat_value,truncate"`
FatValue int `json:"fat_value" bson:"fat_value,truncate"`

Copilot uses AI. Check for mistakes.
Comment on lines +321 to +333
MonounsaturatedFat100g float64 `json:"monounsaturated-fat_100g" bson:"monounsaturated-fat_100g,truncate"`
EnergyUnit string `json:"energy_unit" bson:"energy_unit"`
Energy100g float64 `json:"energy_100g" bson:"energy_100g,truncate"`
PolyunsaturatedFatValue float64 `json:"polyunsaturated-fat_value" bson:"polyunsaturated-fat_value,truncate"`
Fat100g float64 `json:"fat_100g" bson:"fat_100g,truncate"`
CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value,truncate"`
EnergyKcalUnit string `json:"energy-kcal_unit" bson:"energy-kcal_unit"`
Sodium float64 `json:"sodium" bson:"sodium,truncate"`
FatUnit string `json:"fat_unit" bson:"fat_unit"`
FruitsVegetablesNutsEstimateFromIngredients100g float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_100g" bson:"fruits-vegetables-nuts-estimate-from-ingredients_100g,truncate"`
FatServing float64 `json:"fat_serving" bson:"fat_serving,truncate"`
Fat float64 `json:"fat" bson:"fat,truncate"`
MonounsaturatedFatServing float64 `json:"monounsaturated-fat_serving" bson:"monounsaturated-fat_serving,truncate"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fat-related fields changed from int to float64. This is a type-breaking change that could affect API consumers expecting integer values. Ensure all clients can handle floating-point values for fat measurements.

Suggested change
MonounsaturatedFat100g float64 `json:"monounsaturated-fat_100g" bson:"monounsaturated-fat_100g,truncate"`
EnergyUnit string `json:"energy_unit" bson:"energy_unit"`
Energy100g float64 `json:"energy_100g" bson:"energy_100g,truncate"`
PolyunsaturatedFatValue float64 `json:"polyunsaturated-fat_value" bson:"polyunsaturated-fat_value,truncate"`
Fat100g float64 `json:"fat_100g" bson:"fat_100g,truncate"`
CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value,truncate"`
EnergyKcalUnit string `json:"energy-kcal_unit" bson:"energy-kcal_unit"`
Sodium float64 `json:"sodium" bson:"sodium,truncate"`
FatUnit string `json:"fat_unit" bson:"fat_unit"`
FruitsVegetablesNutsEstimateFromIngredients100g float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_100g" bson:"fruits-vegetables-nuts-estimate-from-ingredients_100g,truncate"`
FatServing float64 `json:"fat_serving" bson:"fat_serving,truncate"`
Fat float64 `json:"fat" bson:"fat,truncate"`
MonounsaturatedFatServing float64 `json:"monounsaturated-fat_serving" bson:"monounsaturated-fat_serving,truncate"`
MonounsaturatedFat100g int `json:"monounsaturated-fat_100g" bson:"monounsaturated-fat_100g,truncate"`
EnergyUnit string `json:"energy_unit" bson:"energy_unit"`
Energy100g float64 `json:"energy_100g" bson:"energy_100g,truncate"`
PolyunsaturatedFatValue int `json:"polyunsaturated-fat_value" bson:"polyunsaturated-fat_value,truncate"`
Fat100g int `json:"fat_100g" bson:"fat_100g,truncate"`
CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value,truncate"`
EnergyKcalUnit string `json:"energy-kcal_unit" bson:"energy-kcal_unit"`
Sodium float64 `json:"sodium" bson:"sodium,truncate"`
FatUnit string `json:"fat_unit" bson:"fat_unit"`
FruitsVegetablesNutsEstimateFromIngredients100g float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_100g" bson:"fruits-vegetables-nuts-estimate-from-ingredients_100g,truncate"`
FatServing int `json:"fat_serving" bson:"fat_serving,truncate"`
Fat int `json:"fat" bson:"fat,truncate"`
MonounsaturatedFatServing int `json:"monounsaturated-fat_serving" bson:"monounsaturated-fat_serving,truncate"`

Copilot uses AI. Check for mistakes.
Comment on lines +331 to +332
FatServing float64 `json:"fat_serving" bson:"fat_serving,truncate"`
Fat float64 `json:"fat" bson:"fat,truncate"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fat-related fields changed from int to float64. This is a type-breaking change that could affect API consumers expecting integer values. Ensure all clients can handle floating-point values for fat measurements.

Copilot uses AI. Check for mistakes.
MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"`
FatValue float64 `json:"fat_value" bson:"fat_value,truncate"`
FruitsVegetablesLegumesEstimateFromIngredientsServing float64 `json:"fruits-vegetables-legumes-estimate-from-ingredients_serving" bson:"fruits-vegetables-legumes-estimate-from-ingredients_serving,truncate"`
ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.

Suggested change
ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"`
ProteinsValue int `json:"proteins_value" bson:"proteins_value,truncate"`

Copilot uses AI. Check for mistakes.
Comment on lines +337 to +345
ProteinsServing float64 `json:"proteins_serving" bson:"proteins_serving,truncate"`
PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"`
TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"`
PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"`
Proteins100g float64 `json:"proteins_100g" bson:"proteins_100g,truncate"`
PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"`
CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"`
SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"`
Proteins float64 `json:"proteins" bson:"proteins,truncate"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.

Suggested change
ProteinsServing float64 `json:"proteins_serving" bson:"proteins_serving,truncate"`
PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"`
TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"`
PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"`
Proteins100g float64 `json:"proteins_100g" bson:"proteins_100g,truncate"`
PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"`
CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"`
SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"`
Proteins float64 `json:"proteins" bson:"proteins,truncate"`
ProteinsServing int `json:"proteins_serving" bson:"proteins_serving,truncate"`
PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"`
TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"`
PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"`
Proteins100g int `json:"proteins_100g" bson:"proteins_100g,truncate"`
PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"`
CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"`
SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"`
Proteins int `json:"proteins" bson:"proteins,truncate"`

Copilot uses AI. Check for mistakes.
Comment on lines +337 to +345
ProteinsServing float64 `json:"proteins_serving" bson:"proteins_serving,truncate"`
PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"`
TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"`
PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"`
Proteins100g float64 `json:"proteins_100g" bson:"proteins_100g,truncate"`
PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"`
CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"`
SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"`
Proteins float64 `json:"proteins" bson:"proteins,truncate"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.

Suggested change
ProteinsServing float64 `json:"proteins_serving" bson:"proteins_serving,truncate"`
PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"`
TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"`
PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"`
Proteins100g float64 `json:"proteins_100g" bson:"proteins_100g,truncate"`
PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"`
CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"`
SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"`
Proteins float64 `json:"proteins" bson:"proteins,truncate"`
ProteinsServing int `json:"proteins_serving" bson:"proteins_serving,truncate"`
PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"`
TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"`
PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"`
Proteins100g int `json:"proteins_100g" bson:"proteins_100g,truncate"`
PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"`
CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"`
SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"`
Proteins int `json:"proteins" bson:"proteins,truncate"`

Copilot uses AI. Check for mistakes.
PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"`
CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"`
SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"`
Proteins float64 `json:"proteins" bson:"proteins,truncate"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant